package _02xml解析_Element对象;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class Demo2 {
    public static void main(String[] args) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document read = reader.read("Day_14\\contact.xml");

        Element root = read.getRootElement();
        List<Element> ele1 = root.elements();
        for (Element e : ele1) {
            System.out.println(e.getName());
        }



        Element contact = root.element("contact");
        List<Element> ele2 = contact.elements();
        for (Element e : ele2) {
            System.out.println(e.getName());
        }
        System.out.println(contact.attributeValue("id"));

    }
}
